insert overwrite table jms_dm.dm_cus_active_laxin_volume_cnt_dt
select
      date_add('{{ execution_date | cst_ds }}',0) as input_time
     ,t2.customer_code
     ,max(t1.customer_name) as customer_name
     ,sum(if(t1.input_time='{{ execution_date | cst_ds }}',t1.waybill_cnt,0)) as waybill_cnt
     ,sum(if(t1.input_time between t2.create_date and'{{ execution_date | cst_ds }}' , waybill_cnt,0)) as acc_waybill_cnt
     ,'{{ execution_date | cst_ds }}' as  date_time
     ,'{{ execution_date | cst_ds }}' as  dt
from
    (
        select
             customer_code
             ,max(customer_name) customer_name
             ,count(waybill_no) as  waybill_cnt
             ,date(input_time) as input_time
        from jms_dwd.dwd_yl_oms_oms_waybill_incre_dt
        where dt between '2023-05-17'  and '{{ execution_date | cst_ds }}'
        --is_delete=1 and is_void=0  --非已删除件，非作废件 --不需要剔除
        --活动开始时间是5月20日,但是开始有数据是2023-05-17
        group by customer_code,date(input_time)
    )t1 right join
    (
        select
         customer_code
        ,date(create_time) as create_date
        from jms_dwd.dwd_yl_new_customer_activity_sp_base
        where status=1 --满足条件的客户
    )t2 on t1.customer_code=t2.customer_code
group by t2.customer_code
distribute by 1;